<template>
  <div class="search-wrapper">
    <div class="search-body">
      <el-row :gutter="30">
        <el-col :span="18">
          <div class="search-input">
            <el-input placeholder="请输入搜索的商品" v-model="inputValue" class="input-with-select search-input">
              <!--              <i class="el-icon-search el-input__icon" slot="suffix"/>-->
            </el-input>
          </div>
          <div class="search-tag">
            <p v-for="(item, index) in tagData" :key="index" :class="item.is_hot ? 'hot-font-color-powder' : 'hot-font-color-black'" @click="clickTag(item.name)">
              {{ item.name }}
            </p>
          </div>
        </el-col>
        <el-col :span="6">
          <el-carousel :interval="3000" indicator-position="none" type="card" height="72px">
            <el-carousel-item v-for="(item, index) in bannerData" :key="index">
              <img :src="item.img" alt="" @click="clickBanner(item.url)"/>
            </el-carousel-item>
          </el-carousel>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script>
import { getGoodsTag } from "@/api/Tag";
import { getAllBanner } from "@/api/Banner";
export default {
  name: "search",
  data() {
    return {
      bannerData: [],
      inputValue: "",
      tagData: [],
    };
  },
  mounted() {
    getGoodsTag().then((res) => (this.tagData = res));
    getAllBanner().then((res) => (this.bannerData = res));
  },
  methods: {
    clickTag(tagName) {
      this.inputValue = tagName;
    },
    clickBanner(url){
      window.open(url, '_blank')
    }
  },
  watch: {
    inputValue(value) {
      this.$emit("searchGoodsName", value);
    },
  },
};
</script>
<style scoped>
.search-wrapper {
  margin-top: 64px;
  display: flex;
  justify-content: center;
  padding: 35px;
}
.search-body {
  width: 1200px;
}
.search-body img {
  width: 100%;
  height: 100%;
}
.search-input .el-input__inner {
  height: 65px !important;
  line-height: 64px !important;
}
.search-wrapper .search-tag {
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
}
.search-wrapper .search-tag p {
  font-size: 13px;
  line-height: 32px;
  padding-right: 13px;
}
.hot-font-color-powder {
  color: #fe4800;
}
.hot-font-color-black {
  color: #333333;
}
.search-wrapper .search-tag p:hover {
  cursor: pointer;
}
</style>